import React, { useState, useEffect } from 'react'
import { Tabs } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { fetchCouponClassify } from '@/services/dataCenter/cardData'
import FormA from './subComp/formA'
import FormB from './subComp/formB'
import FormC from './subComp/formC'
const { TabPane } = Tabs

const CardDataForm = props => {
  const [counpClassify, setCounpClassify] = useState([])
  useEffect(() => {
    _fetchCouponClassify()
  }, [])
  // 发放类型
  const couponSendTypes = [
    { label: '全部', value: 0},
    { label: '手工发送', value: 1},
    { label: '自助领取', value: 2},
    { label: '活动赠送', value: 3},
  ]
  // 优惠券类型
  const couponTypes = [
    { label: '满减', value: 1},
    { label: '折扣', value: 2},
  ]
  // 优惠券状态
  const couponStatuses = [
    { label: '未开始', value: 0},
    { label: '进行中', value: 1},
    { label: '已结束', value: 2},
  ]
  // 核券场景
  const scenesList = [
    { label: 'POS核销', value: 1},
    { label: '单柜核销', value: 2},
    { label: '微店核销', value: 3},
    { label: '员工核销', value: 4},
  ]
  const _fetchCouponClassify = async () => {
    let param = {
      supplierId: 1072,
      pageNo: 1,
      pageSize: 99999
    }
    const res = await fetchCouponClassify(param)
    if (res.code == 0) {
      setCounpClassify(res.data)
    }
  }
  return (<PageHeaderWrapper>
    <Tabs>
      <TabPane tab="优惠券" key="1">
        <FormA counpClassify={counpClassify} couponSendTypes={couponSendTypes} couponTypes={couponTypes} couponStatuses={couponStatuses} scenesList={scenesList}/>
      </TabPane>
      <TabPane tab="已领取优惠券" key="2">
        <FormB counpClassify={counpClassify} couponSendTypes={couponSendTypes} couponTypes={couponTypes} couponStatuses={couponStatuses} scenesList={scenesList}/>
      </TabPane>
      <TabPane tab="领取/使用记录" key="3">
        <FormC counpClassify={counpClassify} couponSendTypes={couponSendTypes} couponTypes={couponTypes} couponStatuses={couponStatuses} scenesList={scenesList}/>
      </TabPane>
    </Tabs>
  </PageHeaderWrapper>)
}

export default CardDataForm
